home *** CD-ROM | disk | FTP | other *** search
/ World of Video / World of Video.iso / gfxprograms / 3dprograms / rayshade-4.0 / fixes / fix025 < prev    next >
Text File  |  1995-02-13  |  9KB  |  311 lines

  1. (Message inbox:1681)
  2. Received: from pop-2.iastate.edu by pop-1.iastate.edu with SMTP
  3.     id AA02732; Thu, 4 Aug 1994 14:20:27 -0500
  4. Received: from theseas.ntua.gr by pop-2.iastate.edu with SMTP
  5.     id AA20489; Thu, 4 Aug 1994 14:19:26 -0500
  6. Received: by theseas.ntua.gr with UUCP; Thu, 4 Aug 1994 22:19:19 +0300
  7. Received: by kriton.UUCP (V1.17-beta/Amiga)
  8.       id <043e@kriton.UUCP>; Thu, 4 Aug 94 22:16:04 EET
  9. Date: Thu, 4 Aug 94 22:16:04 EET
  10. Message-Id: <9408042016.043e@kriton.UUCP>
  11. In-Reply-To: <9408040552.AA03514@alpha3.bogus.iastate.edu>
  12.          (from <explorer@iastate.edu>)
  13.          (at Thu, 4 Aug 1994 00:52:07 -0500)
  14. X-Mailer: //\\miga Electronic Mail (AmiElm 3.99)
  15. Organization: My Home
  16. Reply-To: kyrimis@theseas.ntua.gr
  17. Content-Length: 7759
  18. From: kriton!kyrimis@theseas.ntua.gr (Kriton Kyrimis)
  19. To: explorer@iastate.edu
  20. Subject: amigraphics.c
  21.  
  22. I followed your suggestion of incorporating the color raypaint patches
  23. into my version.  Adapting the Amiga display code proved much easier
  24. than I thought, and the result was certainly worth the trouble, even
  25. with a 32-color palette.  I'm sending you the diffs to amigraphics.c to
  26. apply for the distribution.
  27. --
  28.     Kriton    (UUCP:     pythia!theseas!kriton!kyrimis)
  29.               (INTERNET: kyrimis@theseas.ntua.gr)
  30. -----
  31. "If they can use their brains, why can't we use ours?"
  32. -----
  33. *** raypaint/amigraphics.c.orig    Thu Aug  4 19:09:25 1994
  34. --- raypaint/amigraphics.c    Thu Aug  4 22:05:41 1994
  35. ***************
  36. *** 1,20 ****
  37.   /*
  38.    * The Amiga version of raypaint will open a 16 gray level black & white
  39. !  * screen of the appropriate size. It will use hires, lace, overscan, or
  40. !  * autoscroll to accommodate the entire picture. Both PAL and NTSC
  41. !  * machines should be catered for.
  42.    * 
  43.    * If you have a three button mouse, the middle button should work as
  44.    * described in the README file. If you do not, pressing both mouse
  45.    * buttons will do the same thing (remember to deactivate any background
  46.    * programs like DMouse that use pressing both mouse buttons to flip
  47. !  * between screens, etc).
  48.    * 
  49.    * The code will only work on version 2.0 or higher of AmigaDOS.
  50.    * 
  51.    * Send comments and bug reports to:
  52.    * 
  53. !  * Kriton Kyrimis    UUCP:     uunet!mcsun!ariadne!theseas!kriton!kyrimis
  54.    *             INTERNET: kyrimis@theseas.ntua.gr
  55.    */
  56.   
  57. --- 1,22 ----
  58.   /*
  59.    * The Amiga version of raypaint will open a 16 gray level black & white
  60. !  * screen or a 8/32 color screen (depending on whether hires is required for
  61. !  * the requested screen width or not) of the appropriate size. It will use
  62. !  * hires, lace, overscan, or autoscroll to accommodate the entire picture.
  63. !  * Both PAL and NTSC machines should be catered for.
  64.    * 
  65.    * If you have a three button mouse, the middle button should work as
  66.    * described in the README file. If you do not, pressing both mouse
  67.    * buttons will do the same thing (remember to deactivate any background
  68.    * programs like DMouse that use pressing both mouse buttons to flip
  69. !  * between screens, etc). Some of these programs can be fooled by pressing
  70. !  * the right mouse button first.
  71.    * 
  72.    * The code will only work on version 2.0 or higher of AmigaDOS.
  73.    * 
  74.    * Send comments and bug reports to:
  75.    * 
  76. !  * Kriton Kyrimis    UUCP:     pythia!theseas!kriton!kyrimis
  77.    *             INTERNET: kyrimis@theseas.ntua.gr
  78.    */
  79.   
  80. ***************
  81. *** 63,74 ****
  82.   static void StripIntuiMessages(struct MsgPort *, struct Window *);
  83.   static struct MsgPort *CreatePort(UBYTE *, LONG);
  84.   static void DeletePort(struct MsgPort *);
  85.   
  86.   struct GfxBase       *GfxBase = NULL;
  87.   struct IntuitionBase *IntuitionBase = NULL;
  88.   
  89.   static struct NewScreen screen = {
  90. !   0, 0, 0, 0, 4, 0, 1, 0, AUTOSCROLL | CUSTOMSCREEN, NULL, "GetAmi", NULL, NULL
  91.   };
  92.   
  93.   UWORD DriPens[] = { (UWORD)~0 };
  94. --- 65,78 ----
  95.   static void StripIntuiMessages(struct MsgPort *, struct Window *);
  96.   static struct MsgPort *CreatePort(UBYTE *, LONG);
  97.   static void DeletePort(struct MsgPort *);
  98. + static void SetupGrayMap(void);
  99. + static void SetupColorMap(int);
  100.   
  101.   struct GfxBase       *GfxBase = NULL;
  102.   struct IntuitionBase *IntuitionBase = NULL;
  103.   
  104.   static struct NewScreen screen = {
  105. !   0, 0, 0, 0, 0, 0, 1, 0, AUTOSCROLL | CUSTOMSCREEN, NULL, NULL, NULL, NULL
  106.   };
  107.   
  108.   UWORD DriPens[] = { (UWORD)~0 };
  109. ***************
  110. *** 109,119 ****
  111.   static volatile int RMB=0;
  112.   static volatile struct MsgPort *HandlerPort;
  113.   
  114.   void
  115. ! GraphicsInit(int xsize, int ysize, char *name)
  116.   {
  117.     BYTE pal;
  118. -   int i;
  119.   
  120.     atexit(Cleanup);
  121.     if ((GfxBase =
  122. --- 113,124 ----
  123.   static volatile int RMB=0;
  124.   static volatile struct MsgPort *HandlerPort;
  125.   
  126. + static int gray, max_colors;
  127.   void
  128. ! GraphicsInit(int xsize, int ysize, char *name, int gray)
  129.   {
  130.     BYTE pal;
  131.   
  132.     atexit(Cleanup);
  133.     if ((GfxBase =
  134. ***************
  135. *** 154,159 ****
  136. --- 159,173 ----
  137.     }else{
  138.       ScreenTags[DISPIDTAG].ti_Data |= NTSC_MONITOR_ID;
  139.     }
  140. +   if (gray) {
  141. +     screen.Depth = 4;
  142. +   }else{
  143. +     if (screen.ViewModes & HIRES) {
  144. +       screen.Depth = 3;
  145. +     }else{
  146. +       screen.Depth = 5;
  147. +     }
  148. +   }
  149.     if ((s = OpenScreenTagList (&screen, ScreenTags)) == NULL){
  150.       fprintf (stderr, "Can't open screen 1\n");
  151.       Cleanup();
  152. ***************
  153. *** 168,181 ****
  154.     }
  155.     vp = &(s->ViewPort);
  156.     rp = w->RPort;
  157. !   for (i=0; i<16; i++) {
  158. !     SetRGB4 (vp, i,  i, i, i);
  159.     }
  160.   
  161.     HandlerTask =
  162.       CreateTask("Raypaint Mouse Handler", 1, (APTR)MouseHandler, 10000);
  163.   }
  164.   
  165.   static int
  166.   IsPAL(void)
  167.   {
  168. --- 182,235 ----
  169.     }
  170.     vp = &(s->ViewPort);
  171.     rp = w->RPort;
  172. !   if (gray) {
  173. !     SetupGrayMap();
  174. !   }else{
  175. !     SetupColorMap(screen.Depth);
  176.     }
  177.   
  178.     HandlerTask =
  179.       CreateTask("Raypaint Mouse Handler", 1, (APTR)MouseHandler, 10000);
  180.   }
  181.   
  182. + static void
  183. + SetupGrayMap()
  184. + {
  185. +   int i;
  186. +   gray = 1;
  187. +   for (i=0; i<16; i++) {
  188. +     SetRGB4 (vp, i,  i, i, i);
  189. +   }
  190. + }
  191. + static void
  192. + SetupColorMap(int depth)
  193. + {
  194. +   int col;
  195. +   int r, g, b, red, green, blue;
  196. +   double one_over_gamma = 0.4;
  197. +   gray = 0;
  198. +   if (depth == 3) {
  199. +     max_colors = 2;
  200. +   }else{
  201. +     max_colors = 3;
  202. +   }
  203. +   col = 0;
  204. +   for (r = 0; r < max_colors; ++r) {
  205. +     red = 15 * r / (max_colors-1);
  206. +     for (g = 0; g < max_colors; ++g) {
  207. +       green = 15 * g / (max_colors-1);
  208. +       for (b = 0; b < max_colors; ++b) {
  209. +         blue = 15 * b / (max_colors-1);
  210. +     SetRGB4 (vp, col++,  red, green, blue);
  211. +       }
  212. +     }
  213. +   }
  214. + }
  215.   static int
  216.   IsPAL(void)
  217.   {
  218. ***************
  219. *** 227,242 ****
  220.   void
  221.   GraphicsDrawPixel(int xp, int yp, unsigned char color[3])
  222.   {
  223. !   int idx;
  224.   
  225.     if (Done) {
  226.       Cleanup();
  227.       exit(RETURN_OK);
  228.     }
  229. !   idx = (((0.35*(double)(color[0]) +
  230. !            0.55*(double)(color[1]) +
  231. !            0.10*(double)(color[2])) * 15.0) / 255.0) + 0.5;
  232. !   SetAPen(rp, idx);
  233.     WritePixel(rp, MAPX(xp), MAPY(yp));
  234.   }
  235.   
  236. --- 281,305 ----
  237.   void
  238.   GraphicsDrawPixel(int xp, int yp, unsigned char color[3])
  239.   {
  240. !   int val;
  241.   
  242.     if (Done) {
  243.       Cleanup();
  244.       exit(RETURN_OK);
  245.     }
  246. !   if (gray) {
  247. !     val = (((0.35*(double)(color[0]) +
  248. !          0.55*(double)(color[1]) +
  249. !          0.10*(double)(color[2])) * 15.0) / 255.0) + 0.5;
  250. !   }else{
  251. !     val = color[0] / 255.0 * (max_colors-1) + 0.5;
  252. !     val *= max_colors;
  253. !     val += color[1] / 255.0 * (max_colors-1) + 0.5;
  254. !     val *= max_colors;
  255. !     val += color[2] / 255.0 * (max_colors-1) + 0.5;
  256. !   }
  257. !   SetAPen(rp, val);
  258.     WritePixel(rp, MAPX(xp), MAPY(yp));
  259.   }
  260.   
  261. ***************
  262. *** 250,265 ****
  263.                         unsigned char ll[3], unsigned char lr[3], 
  264.                         unsigned char ur[3], unsigned char ul[3])
  265.   {
  266. !   int idx;
  267.   
  268.     if (Done) {
  269.       Cleanup();
  270.       exit(RETURN_OK);
  271.     }
  272. !   idx = (((0.35*(double)(ll[0]) +
  273. !            0.55*(double)(ll[1]) +
  274. !            0.10*(double)(ll[2])) * 15.0) / 255.0) + 0.5;
  275. !   SetAPen(rp, idx);
  276.     RectFill(rp, MAPX(xp), MAPY(yp+ys), MAPX(xp+xs), MAPY(yp));
  277.   }
  278.   
  279. --- 313,336 ----
  280.                         unsigned char ll[3], unsigned char lr[3], 
  281.                         unsigned char ur[3], unsigned char ul[3])
  282.   {
  283. !   int val;
  284.   
  285.     if (Done) {
  286.       Cleanup();
  287.       exit(RETURN_OK);
  288.     }
  289. !   if (gray) {
  290. !     val = (((0.35*(double)(ll[0]) +
  291. !          0.55*(double)(ll[1]) +
  292. !          0.10*(double)(ll[2])) * 15.0) / 255.0) + 0.5;
  293. !   }else{
  294. !     val = ll[0] / 255.0 * (max_colors-1) + 0.5;
  295. !     val *= max_colors;
  296. !     val += ll[1] / 255.0 * (max_colors-1) + 0.5;
  297. !     val *= max_colors;
  298. !     val += ll[2] / 255.0 * (max_colors-1) + 0.5;
  299. !   }
  300. !   SetAPen(rp, val);
  301.     RectFill(rp, MAPX(xp), MAPY(yp+ys), MAPX(xp+xs), MAPY(yp));
  302.   }
  303.   
  304.